<%@ page language="java" %>
<%@ page import="java.util.ArrayList,
				java.util.Date,
				com.scalar.chiptrack.utils.StringUtils,
                com.scalar.chiptrack.operations.process.ChiptrackProduct,
                com.scalar.chiptrack.utils.ConfigManager"%>

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<html:html>
<%String chipTracContext = "/" + ConfigManager.getChipTracContext();
  String year = "";

	try
	{
      year = request.getAttribute( "dateYear" ).toString();
    }
     catch ( NullPointerException e )
     {
         year = StringUtils.formatDateToString(new Date(), "yyyy");
     }
%>

<HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<meta http-equiv="Expires" content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>

<BODY bgColor="#ffffff" leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">
<script src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></script>
<script language='javascript'>
	function searchProducts() {
		var pa = document.getElementById("errors");
		pa.innerHTML = "";
		var a1 = document.updateViewCostForm.productId.value.trim();
		if ( ( a1 == '' ) || ( a1 == '0' ) || ( a1 == '-1' ) )
		{
			pa.innerHTML = "<li> Please select a valid base product";
			document.updateViewCostForm.productId.focus();
			return;
		}
		document.updateViewCostForm.action.value = "search";
		document.updateViewCostForm.submit();
	}


	// Added By Basha (07/31/2003)
	function showErrorReportPage()
	{
		newWindow = window.open ('<%=chipTracContext%>/reportProblem.do','reportProblem','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=750,height=400,resizable=no');
		newWindow.focus();
	}

</script>

<!-- Top Header Start-->
<%@ include file="/jsp/includes/header.jsp" %>
<!-- Top Header End-->

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
	<td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>

	<!-- Side Navigation start -->
	<%@ include file="/jsp/finance/finance_menu.jsp" %>
	<!-- end of the side navigations -->

	<TD bgcolor="#ffffff">
	<IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
	<TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
	<TD valign="top" width="100%">

	<IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
	<BR>


	<!-- BODY STARTS HERE -->

	<center><span class="NArialW">Update/View Cost</span></center>
	<img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10>

	<html:form name="updateViewCostForm" type="com.scalar.chiptrack.finance.forms.UpdateViewCostForm" onsubmit="javascript:searchProducts()" action="/updateViewCost.do">

	<table border="0" width="90%" align="center">
	 <tr><td>
		<table border="0" width="95%" align='left'>
			<tr><td colspan='4'><chiptrack:errors styleClass='NArialL'/></td></tr>
			<tr><td colspan='4'><chiptrack:info styleClass='NArialL'/></td></tr>
			<tr><td colspan='4' align="left" class='NArialL'>&nbsp;<FONT id="errors" color='FF0000'></font></td></tr>
            <tr><td colspan='4'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=5></td></tr>

			<tr>
			<td width="25%" class="NArialL">Select Base Product:</td>
			<td width="30%" align = "left" class="NArialL">
			    <html:select property="productId" styleClass="txfield">
				<html:option value="-1">Select Base Product</html:option>
				<html:options collection="finalMktProdList" property="value" labelProperty="label"/>
				</html:select>
            </td>
			<td width="10%" align = "left" class="NArialL">Year:&nbsp;&nbsp;</td>
			<td width="35%">
			    <html:select size="1" property="dateYear" styleClass="txfield">
				<html:options collection="yearList" property="value" labelProperty="label"/>
				</html:select>
            </td>
			</tr>
            
			<tr><td colspan='4' class="NArialRS">&nbsp;</td></tr>
            <tr>
				<td colspan='4' align="center" class="NArialL">&nbsp;&nbsp;&nbsp;&nbsp;
				<a href="javascript:searchProducts()"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/search.gif" width="53" height="17" onMouseOver="window.status='Click  to start search';return true" onmouseout="window.status='';return true" title="Click here to Search for Products"></a>
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				<%-- <a href="<%=chipTracContext%>/updateViewCost.do">
				<img border="0" src="<%=chipTracContext%>/jsp/includes/images/cancel.gif" width="53" height="17" onMouseOver="window.status='Click  to cancel search';return true" onmouseout="window.status='';return true" title="Click here To Cancel Search "></a> --%>
                <a href="javascript:document.updateViewCostForm.reset();"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" onMouseOver="window.status='Click to Reset';return true" onmouseout="window.status='';return true" title="Click here to Reset"></a></td>
            </tr>
            <tr><td colspan='4'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td></tr>
            <tr><td colspan='4' align="left" class='NArialL'><a href="<%=chipTracContext%>/updateViewCost.do?action=updateAllCurrentQuarterValues" class="leftsection">Update Current Quarter Values </a> &nbsp;&nbsp; For All Base Products&nbsp;&nbsp;</td></tr>
        </table>
		 <!--These hidden field is added to send the action value to action class so that search functionality can be incorporated.-->
		<input type="hidden" name="action">
	 </td></tr>

	 <tr><td><img height=10 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></td></tr>

	 <tr><td>
		<table border="1" width="80%" bordercolor="#FFFFFF" align='left'>
        <logic:equal name="action" value="search">
        <%
            ArrayList marketingProductList = (ArrayList) request.getAttribute ("marketingProductList");
            if (marketingProductList == null) marketingProductList = new ArrayList();

            int marketingProductListSize = marketingProductList.size();

            if (marketingProductListSize == 0) {
            }
            else {
        %>

        <tr>
            <td width="30%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">Product Name</font></td>
            <td width="25%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">Standard Cost</font></td>
            <td width="25%" align="center" bgcolor="#993333" class="NArialL"><font color="#FFFFFF">Projected Cost</font></td>
        </tr>

        <%
            ChiptrackProduct product = null;
            for (int i=0; i<marketingProductListSize; i++) {
                product = (ChiptrackProduct) marketingProductList.get (i);
        %>

		<tr>
            <td width="20%" align="center"  class="NArialL" bgcolor="#DEE1E2">&nbsp;<%=product.getProductName()%></td>

            <td width="30%" align="left" nowrap bgcolor="#DEE1E2" class="NArialL">
            <% if ( user.isActionAllowed( Functionality.UPDATE_VIEW_COST, User.USER_ACTION_MODIFY ) ){ %>
            <a href="updateViewCost.do?action=allowupdate&productId=<%= product.getProductId() %>&productName=<%= product.getProductName() %>&dateYear=<%= year%>" onMouseOver="window.status='Click to Update Standard Cost Information';return true" onmouseout="window.status='';return true">Update</a>
            <% } else {%> Update <%}if ( user.isActionAllowed( Functionality.UPDATE_VIEW_COST, User.USER_ACTION_VIEW ) ){ %>
            &nbsp;&nbsp;&nbsp;&nbsp; <a href="updateViewCost.do?action=view&productId=<%= product.getProductId()%>&productName=<%= product.getProductName()%>&dateYear=<%=year%>" onMouseOver="window.status='Click to View Standard Cost Information';return true" onmouseout="window.status='';return true">View</a>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="updateViewCost.do?action=exportToExcel&costType=Standard&productId=<%= product.getProductId() %>&productName=<%= product.getProductName() %>&dateYear=<%= year%>" onMouseOver="window.status='Click to Export Standard Cost Information';return true" onmouseout="window.status='';return true">ExportToExcel</a>
            </td>
            <% } else {%> View <%}%>
            
            <td width="30%" align="left" nowrap bgcolor="#DEE1E2" class="NArialL">
            <% if ( user.isActionAllowed( Functionality.UPDATE_VIEW_COST, User.USER_ACTION_MODIFY ) ){ %>
            <a href="updateViewCost.do?action=prjallowupdate&productId=<%= product.getProductId() %>&productName=<%= product.getProductName() %>&dateYear=<%= year%>" onMouseOver="window.status='Click to Update Projected Cost Information';return true" onmouseout="window.status='';return true">Update</a>
            <% } else {%> Update <%}if ( user.isActionAllowed( Functionality.UPDATE_VIEW_COST, User.USER_ACTION_VIEW ) ){ %>
            &nbsp;&nbsp;&nbsp;&nbsp; <a href="updateViewCost.do?action=prjview&productId=<%= product.getProductId()%>&productName=<%= product.getProductName()%>&dateYear=<%=year%>" onMouseOver="window.status='Click to View Projected Cost Information';return true" onmouseout="window.status='';return true">View</a>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="updateViewCost.do?action=exportToExcel&costType=Projected&productId=<%= product.getProductId() %>&productName=<%= product.getProductName() %>&dateYear=<%= year%>" onMouseOver="window.status='Click to Export Projected Cost Information';return true" onmouseout="window.status='';return true">ExportToExcel</a>
            </td>
            <% } else {%> View <%}%>
        </tr>
	      <%
                }
            }
		    %>

		</logic:equal>
		</table>

	 </td></tr>
	 </table>
     </html:form>   
	<!-- BODY ENDS HERE -->
	<BR><BR><BR></TD>
	<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
	</TR>
	</TABLE>

	<!-- Footer starts here -->
	<%@ include file="/jsp/includes/footer.jsp" %>
	<!-- footer end here -->
	</body>

</html:html>
